﻿using System;
using Lintop.ePos.Common.DataAccess;

namespace PowerToolsWeb.DataAccess
{
    public partial class Tpt_Message : DataAccessBase
    {
        //TODO: 请把你的方法添加在这里
        public bool SetReaded(int msgId)
        {
            string sql = @"update Tpt_Message set IsRead=1 where MESSAGEID="+msgId;
            return UpdateBySql(sql);
        }
    }

    public partial class Tpt_MessageCollection : DataAccessCollectionBase
    {
        //TODO: 请把你的方法添加在这里
        public bool ListMsg(int read, DateTime startDT, DateTime endDT)
        {
            string sql = @"SELECT *
                            FROM  Tpt_Message  
                            where (CreatTime >= datetime('{0}')) 
                            AND (CreatTime <= datetime('{1}'))";
            sql = string.Format(sql, startDT.ToString("yyyy-MM-dd HH:mm:ss"), endDT.AddDays(1).ToString("yyyy-MM-dd HH:mm:ss"));
            if (read != -1)
            {
                sql += " and IsRead=" + read;
            }
            sql += " order by CreatTime desc";
            return ListBySql(sql);
        }
    }
}
